From e5571af7d1f1b2d08694c71a9dae391806f3baea Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 23 Mar 2015 18:01:27 -0700 Subject: [PATCH] Add a test for tests in benchmarks Closes #727 --- tests/test_cargo_bench.rs | 37 +++++++++++++++++++++++++++++++++++ tests/test_cargo_freshness.rs | 4 ++++ 2 files changed, 41 insertions(+) diff --git a/tests/test_cargo_bench.rs b/tests/test_cargo_bench.rs index e5009e3f3..6ebf0e31f 100644 --- a/tests/test_cargo_bench.rs +++ b/tests/test_cargo_bench.rs @@ -855,3 +855,40 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 1 measured dir = p.root().display(), url = p.url()).as_slice())); }); + +test!(test_a_bench { + let p = project("foo") + .file("Cargo.toml", r#" + [project] + name = "foo" + authors = [] + version = "0.1.0" + + [lib] + name = "foo" + test = false + doctest = false + + [[bench]] + name = "b" + test = true + "#) + .file("src/lib.rs", "") + .file("benches/b.rs", r#" + #[test] + fn foo() {} + "#); + + assert_that(p.cargo_process("test"), + execs().with_status(0) + .with_stdout(format!("\ +{compiling} foo v0.1.0 ([..]) +{running} target[..]debug[..]b-[..] + +running 1 test +test foo ... ok + +test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured + +", compiling = COMPILING, running = RUNNING))); +}); diff --git a/tests/test_cargo_freshness.rs b/tests/test_cargo_freshness.rs index 24fce3aa4..68c94c625 100644 --- a/tests/test_cargo_freshness.rs +++ b/tests/test_cargo_freshness.rs @@ -77,6 +77,8 @@ test!(modify_only_some_files { p.root().move_into_the_past().unwrap(); File::create(&bin).unwrap().write_all(b"fn foo() {}").unwrap(); + // p.root().move_into_the_past().unwrap(); + // p.root().join("target").move_into_the_past().unwrap(); // Make sure the binary is rebuilt, not the lib assert_that(p.cargo("build") @@ -195,6 +197,8 @@ test!(rebuild_tests_if_lib_changes { execs().with_status(0)); File::create(&p.root().join("src/lib.rs")).unwrap(); + p.root().move_into_the_past().unwrap(); + p.root().join("target").move_into_the_past().unwrap(); assert_that(p.cargo("build"), execs().with_status(0)); -- 2.30.2